// var baseurl = "http://120.25.251.98:8084/"
var baseurl = "http://47.108.197.28:4000/"
function http({
    url
}){
    return new Promise((resolve,reject)=>{
        wx.request({
            url: baseurl+url,
            data: {},
            header: {'content-type':'application/json'},
            method: 'GET',
            dataType: 'json',
            responseType: 'text',
            success: (res)=>{
                resolve(res)
            },
            fail: (err)=>{
                reject(err)
            },
        });
    })
}
function getArticleList(){
    return http({
        url:"article",
    })
}
function getArticleDtail(id){
    return http({
        url:`api/articleDetail?id=${id}`,
    })
}
function getArticleCollect({
    url,id,collected
}){
    wx.request({
        url: baseurl+url,
        data: {id,collected},
        header: {'content-type':'application/x-www-form-urlencoded'},
        method: 'POST',
        dataType: 'json',
        responseType: 'text',
    });
}
function getArticleHistory(){
    return http({
        url:"api/history?id=6041909ec29db040c49fd554&m=top250",
    })
}
//  moviedetail     /api/detail?id=60418facc29db040c49fd52b
//  search          /api/search?keyword=nihao
//  movieCollect    /api/collectMovie/:m
module.exports = {
    http,
    getArticleDtail,
    getArticleList,
    getArticleCollect,
    getArticleHistory
}